package com.qingfeng.testandroid12sdkdemo.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.qingfeng.testandroid12sdkdemo.R;
import com.qingfeng.testandroid12sdkdemo.data.entity.CustomViewsInfo;
import com.stx.xhb.androidx.XBanner;
import com.stx.xhb.androidx.entity.BaseBannerInfo;

import java.util.ArrayList;
import java.util.List;

public class TestVideoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_video);
        initView();
    }


    private void initView() {
        XBanner banner = (XBanner) findViewById(R.id.banner);
        List<CustomViewsInfo> data = new ArrayList<>();
        data.add(new CustomViewsInfo("https://photo.tuchong.com/250829/f/31548923.jpg"));
        data.add(new CustomViewsInfo("https://photo.tuchong.com/46728/f/20138526.jpg"));
        data.add(new CustomViewsInfo("https://photo.tuchong.com/392724/f/16858773.jpg"));
        data.add(new CustomViewsInfo("https://photo.tuchong.com/408963/f/18401047.jpg"));
        final BannerHolderCreator holderCreator = new BannerHolderCreator();
        banner.setBannerData(data,holderCreator);
        banner.setOnItemClickListener(new XBanner.OnItemClickListener() {

            @Override
            public void onItemClick(XBanner banner, Object model, View view, int position) {
                ToastUtils.showShort("点击了" + position);
            }
        });
        banner.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {
                Log.i("onPageScrolled=", i + "");
            }

            @Override
            public void onPageSelected(int i) {
                Log.i("onPageSelected=", i + "");
                /*if (i == 0) {
                    holderCreator.videoViewHolder.videoView.start();
                } else {
                    holderCreator.videoViewHolder.videoView.pause();
                }*/
            }

            @Override
            public void onPageScrollStateChanged(int i) {
                Log.i("ScrollStateChanged=", i + "");
            }
        });
    }
}